(function () {
    'use strict';
    const loginForm = $('#loginForm');
    loginForm.on('submit', function () {
        let data = $(this).serializeArray();
        $.post('/login/in', data, function (res) {
            if (res && res.errno === 0) {
                const {role} = res.data;
                if (role === 'admin') {
                    location.href = '/admin/index'
                } else if (role === 'user') {
                    location.href = '/users'
                }
            }
        }, 'json');
        return false
    });
})();